home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ABERMUD.ZIP / BLOOD.C < prev    next >
C/C++ Source or Header  |  1989-07-08  |  5KB  |  250 lines

  1. #include <stdio.h>
  2. #include "files.h"
  3. #include "System.h"
  4.  
  5.  
  6.  
  7. long in_fight=0;
  8. long  fighting= -1;
  9.  
  10.  
  11.  
  12. int dambyitem(it)
  13. long it;
  14.     {
  15.     switch(it)
  16.        {
  17. case -1:return(4);
  18. default:if(!otstbit(it,15))return(-1);
  19. else return(obyte(it,0));
  20.           }
  21.  
  22.     }
  23.  
  24. long wpnheld= -1;
  25.  
  26. void weapcom()
  27.     {
  28.     long a,b;
  29.     if(brkword()== -1)
  30.        {
  31.        bprintf("Which weapon do you wish to select though\n");
  32.        return;
  33.        }
  34.     a=fobnc(wordbuf);
  35.     if(a== -1)
  36.        {
  37.        bprintf("Whats one of those ?\n");
  38.        return;
  39.        }
  40.     b=dambyitem(a);
  41.     if(b<0)
  42.        {
  43.        bprintf("Thats not a weapon\n");
  44.        wpnheld= -1;
  45.        return;
  46.        }
  47.     wpnheld=a;
  48.         calibme();
  49.     bprintf("OK...\n");
  50.     }
  51.  
  52. void hitplayer(victim,wpn)
  53.  long victim,wpn;
  54.     {
  55.     long a,b,c,d;
  56.     extern long my_lev,my_str;
  57.     extern long wpnheld;
  58.     long z;
  59.     long x[4];
  60.     long cth,ddn,res;
  61.     if(!strlen(pname(victim))) return;
  62.     /* Chance to hit stuff */
  63.     if((!iscarrby(wpn,mynum))&&(wpn!= -1))
  64.        {
  65.        if(wpnheld==wpn) wpnheld= -1;
  66.        wpn= -1;
  67.        }
  68.     wpnheld=wpn;
  69.     if((wpn==32)&&(iscarrby(16,victim)))
  70.     {
  71.         return;
  72.     }
  73.     if(dambyitem(wpn)<0)
  74.        {
  75.        bprintf("Thats no good as a weapon\n");
  76.        wpnheld= -1;
  77.        return;
  78.        }
  79.     if(in_fight)
  80.     {
  81.         bprintf("You are already fighting!\n");
  82.         return;
  83.     }
  84.     fighting=victim;
  85.     in_fight=300;
  86.     res=randperc();
  87.     cth=40+3*my_lev;
  88.     if((iswornby(89,victim))||(iswornby(113,victim))||(iswornby(114,victim)))
  89.         cth-=10;
  90.     if(cth<0) cth=0;
  91.     if(cth>res)
  92.         {
  93.            bprintf("You hit \001p%s\001 ",pname(victim));
  94.             if(wpn!= -1)bprintf("with the %s",oname(wpn));
  95.            bprintf("\n");
  96.            ddn=randperc()%(dambyitem(wpn));
  97.            x[0]=mynum;
  98.            x[1]=ddn;
  99.            x[2]=wpn;
  100.            if(pstr(victim)-ddn<0)
  101.         {
  102.             bprintf("Your last blow did the trick\n");
  103.             if(pstr(victim)>=0)
  104.             {
  105. /* Bonus ? */
  106.                 if(victim<16) my_sco+=(plev(victim)*plev(victim)*100);
  107.                 else my_sco+=10*damof(victim);
  108.             }
  109.             setpstr(victim,-1); /* MARK ALREADY DEAD */
  110.             in_fight=0;
  111.             fighting= -1;
  112.         }
  113.        if(victim<16)sendsys(pname(victim),globme,-10021,curch,(char *)x);
  114.        else
  115.               {
  116.               woundmn(victim,ddn);
  117.               }
  118.        my_sco+=ddn*2;
  119.        calibme();
  120.        return;
  121.        }
  122.     else
  123.        {
  124.            bprintf("You missed \001p%s\001\n",pname(victim));
  125.            x[0]=mynum;
  126.            x[1]= -1;
  127.            x[2]=wpn;
  128.            if(victim<16) sendsys(pname(victim),globme,-10021,curch,(char *)x);
  129.              else
  130.         woundmn(victim,0);
  131.        }
  132.     }
  133.  
  134.  killcom()
  135.     {
  136.     long vic,a;
  137.     long x;
  138.     if(brkword()== -1)
  139.        {
  140.        bprintf("Kill who\n");
  141.        return;
  142.        }
  143.     if(!strcmp(wordbuf,"door"))
  144.     {
  145.         bprintf("Who do you think you are , Moog ?\n");
  146.         return;
  147.     }
  148.     if(fobna(wordbuf)!= -1)
  149.        {
  150.            breakitem(fobna(wordbuf));
  151.            return;
  152.        }
  153.     if((a=fpbn(wordbuf))== -1)
  154.        {
  155.            bprintf("You can't do that\n");
  156.            return;
  157.        }
  158.     if(a==mynum)
  159.        {
  160.            bprintf("Come on, it will look better tomorrow...\n");
  161.            return;
  162.        }
  163.     if(ploc(a)!=curch)
  164.        {
  165.            bprintf("They aren't here\n");
  166.            return;
  167.        }
  168.     xwisc:if(brkword()== -1)
  169.        {
  170.            hitplayer(a,wpnheld);
  171.            return;
  172.        }
  173.     if(!strcmp(wordbuf,"with"))
  174.        {
  175.            if(brkword()== -1)
  176.               {
  177.                   bprintf("with what ?\n");
  178.                   return;
  179.               }
  180.            }
  181.         else
  182.            goto xwisc;
  183.         x=fobnc(wordbuf);
  184.         if(x== -1)
  185.            {
  186.                bprintf("with what ?\n");
  187.                return;
  188.            }
  189.     hitplayer(a,x);
  190.     }
  191.  
  192.  
  193. void  bloodrcv(array,isme)
  194.  long *array;
  195.     {
  196.     long x;
  197.     char ms[128];
  198.     if(!isme) return; /* for mo */
  199.     if(array[0]<0) return;
  200.     nlod:if(!strlen(pname(array[0]))) return;
  201.     fighting=array[0];
  202.     in_fight=300;
  203.     if(array[1]== -1)
  204.        {
  205.        bprintf("\001p%s\001 attacks you",pname(array[0]));
  206.        if(array[2]!= -1)bprintf(" with the %s",oname(array[2]));
  207.        bprintf("\n");
  208.        }
  209.     else
  210.        {
  211.        bprintf("You are wounded by \001p%s\001",pname(array[0]));
  212.        if(array[2]>-1)bprintf(" with the %s",oname(array[2]));
  213.        bprintf("\n");
  214.        if(my_lev<10){my_str-=array[1];
  215.     if(array[0]==16) {
  216.             my_sco-=100*array[1];
  217.         if(my_sco<0) my_str= -1;
  218.         }
  219.     }
  220.     if(my_str<0)
  221.     {
  222.           syslog("%s slain by %s",globme,pname(array[0]));
  223.           dumpitems();
  224.           loseme();
  225.           closeworld();
  226.           delpers(globme);
  227.           openworld();
  228.           sprintf(ms,"\001p%s\001 has just died.\n",globme);
  229.           sendsys(globme,globme,-10000,curch,ms);
  230.           sendsys(globme,globme,-10113,curch,ms);
  231.           crapup("Oh dear... you seem to be slightly dead\n");
  232.           }
  233.        me_cal=1; /* Queue an update when ready */
  234.        }
  235.     }
  236.  
  237.  
  238. void  breakitem(x)
  239.     {
  240.     switch(x)
  241.        {
  242.     case 171:sys_reset();break;
  243.     case -1:
  244.           bprintf("What is that ?\n");break;
  245.        default:
  246.           bprintf("You can't do that\n");
  247.           }
  248.     }
  249.     
  250.